def filewrite(file_name):
    fo = open(filename,"w+")
    print('请输入内容(输入s终止输入并保存)：')
    while True:
        write_text = input()
        if write_text != 's':
            fo.write('%s\n' % write_text)
        else:
            break
    fo.close
filename='D:\hello.txt'
filewrite(filename)
